<?php
if(!defined('ADMINPX') || !defined('ADMIN')) {
	exit('Access Denied');
}
$act=$_GET['act'];
$qid=$_GET['qid'];
$fid=$_GET['fid'];
$uid=$_GET['uid'];
$aa=$_GET['aa'];
if($act=='hbtz'){
echo <<<end
<div class="admin">论坛帖子合并<br/></div>
<form method="POST" action="admin.php?action=forum_admin&act=hbtzok&fid=$fid" >
<b>选择被合并论坛</b><select name="uid">
end;
$sql_c=$db->query('forum_class'," ORDER BY `id` ","");
while($row_ac=mysql_fetch_array($sql_c)){
   echo"<option value=\"$row_ac[id]\">$row_ac[name](id:$row_ac[id])</option>";
}
echo <<<end
</select>
<br/>
<b>选择合并论坛</b><select name="fid">
end;
$sql_c=$db->query('forum_class'," ORDER BY `id` ","");
while($row_ac=mysql_fetch_array($sql_c)){
   echo"<option value=\"$row_ac[id]\">$row_ac[name](id:$row_ac[id])</option>";
}
echo <<<end
</select>
<br/>
<input type="submit" value="确定合并" name="adminpost" />
</form><br/>
注意：合并后被合并论坛帖子数据全部在合并论坛里，请认真操作。<br/>
end;
}else if($act=='hbtzok'){
	if(!$_POST[adminpost]){
	  echo"提交出错<br/>";
	}elseif(!$row=$db->get_one('forum_class'," `id` ='$_POST[uid]'",'')){
		echo"<br/>出错！论坛id错误！</strong><br/>";
  }else if(!$row=$db->get_one('forum_class'," `id` ='$_POST[fid]'",'')){
		echo"<br/>出错！论坛id错误！</strong><br/>";
  }else{
    $sql_c=$db->query('forum'," `cid` ='$_POST[uid]' ","id");
    while($row_ac=mysql_fetch_array($sql_c)){
    	    $sql=$db->query('forum_hui'," `fid` ='$row_ac[id]' ","id");
    	    while($row=mysql_fetch_array($sql)){
    	    	$db->update('forum_hui',array('cid' => $_POST[fid] )," `id`= '$row[id]'");
    	    }
    	    $db->update('forum',array('cid' => $_POST[fid] )," `id`= '$row_ac[id]'");
          $a++;
    }
		echo"<br/>操作成功！<br/>合并帖子{$a}条<br/>";
  }
  echo "正在自动返回.......<br/><a href=\"admin.php?action=forum\">请手动返回</a><br/><meta http-equiv=refresh content='3;url=admin.php?action=forum'>";
}else if($act=='zjbzok'){
	if(!$_POST[adminpost]){
	  echo"提交出错<br/>";
	}elseif(!$row=$db->get_one('user'," `uid` ='$_POST[uid]'",'')){
		echo"<br/>出错！会员UID错误！</strong><br/>";
  }else if($row=$db->get_one('forum_admin'," `type` ='0' AND `fid` ='$fid' AND `uid` ='$_POST[uid]'",'')){
		echo"<br/>出错！会员已经是该论坛版主了！</strong><br/>";
  }else if($db->insert('forum_admin',array('id' => 'NULL', 'uid' => $_POST[uid], 'fid' => $fid, 'type' => '0'))){
    $rowbz=$db->get_one('forum_class'," `id` ='$fid'",'');
    $xxsj="你好！你被设置为【[url=index.php?$bzml=forum&amp;$bzmd=viewthread&amp;fid=$rowbz[id][bzsid]]$rowbz[name][/url]】论坛版主，请管理好该论坛一切事务。";
    Bingz_message_post('0', $_POST[uid],$xxsj);
		echo"<br/>增加版主成功！<br/>";
  }else{
		echo"<br/>增加版主失败！<br/>";
  }
  echo "正在自动返回.......<br/><a href=\"admin.php?action=forum_admin\">请手动返回</a><br/><meta http-equiv=refresh content='3;url=admin.php?action=forum_admin'>";
}else if($act=='zjqzok'){
	if(!$_POST[adminpost]){
	  echo"提交出错<br/>";
	}elseif(!$row=$db->get_one('user'," `uid` ='$_POST[uid]'",'')){
		echo"<br/>出错！会员UID错误！</strong><br/>";
  }else if($row=$db->get_one('forum_admin'," `type` ='1' AND `fid` ='$fid' AND `uid` ='$_POST[uid]'",'')){
		echo"<br/>出错！会员已经是该区主了！</strong><br/>";
  }else if($db->insert('forum_admin',array('id' => 'NULL','uid' => $_POST[uid],'fid' => $fid,'type' => 1))){
    $rowbz=$db->get_one('forum_class_fl'," `id` ='$fid'",'');
    $xxsj="你好！你被设置为【[url=index.php?$bzml=forum&amp;fid=$rowbz[id]]$rowbz[name][/url]】区主，请管理好该区块论坛一切事务。";
    Bingz_message_post('0', $_POST[uid],$xxsj);
		echo"<br/>增加区主成功！<br/>";
  }else{
		echo"<br/>增加区主失败！<br/>";
  }
  echo "正在自动返回.......<br/><a href=\"admin.php?action=forum_admin\">请手动返回</a><br/><meta http-equiv=refresh content='3;url=admin.php?action=forum_admin'>";
}else if($act=='zjbz'){
  $row=$db->get_one('forum_class'," `id` ='$fid'",'');
echo <<<end
<div class="admin">增加论坛【$row[name]】版主<br/></div>
<form method="POST" action="admin.php?action=forum_admin&act=zjbzok&fid=$fid" >
选择版主<select name="uid">
end;
$rowqx=$db->get_one('user_qxz',"`qxid` ='5' and `type_a` ='1' ",'');
$sql_c=$db->query('user',"`user_qx` ='$rowqx[id]' ORDER BY `uid` ","");
while($row_ac=mysql_fetch_array($sql_c)){
   echo"<option value=\"$row_ac[uid]\">$row_ac[name](uid:$row_ac[uid])</option>";
}
echo <<<end
</select>
<input type="submit" value="确定增加版主" name="adminpost" /><br/>
</form>
end;
}else if($act=='zjqz'){
  $row=$db->get_one('forum_class_fl'," `id` ='$fid'",'');
echo <<<end
<div class="admin">增加【$row[name]】区主<br/></div>
<form method="POST" action="admin.php?action=forum_admin&act=zjqzok&fid=$fid" >
选择版主<select name="uid">
end;
$rowqx=$db->get_one('user_qxz'," `qxid` ='5' and `type_a` ='1' ",'');
$sql_c=$db->query('user',"`user_qx` ='$rowqx[id]' ORDER BY `uid` ","");
while($row_ac=@mysql_fetch_array($sql_c)){
   echo"<option value=\"$row_ac[uid]\">$row_ac[name](uid:$row_ac[uid])</option>";
}
echo <<<end
</select>
<input type="submit" value="确定增加区主" name="adminpost" /><br/>
</form>
end;
}else if($act=='scbz'){
    $row=$db->get_one('forum_admin'," `id` ='$fid'",'');
    $rowbz=$db->get_one('forum_class'," `id` ='$row[cid]'",'');
    $xxsj="你好！你在【[url=index.php?$bzml=forum&amp;$bzmd=viewthread&amp;fid=$rowbz[id][bzsid]]$rowbz[name][/url]】论坛的版主权限，被管理员解除。";
    Bingz_message_post('0',$row[uid],$xxsj);
    $db->delete('forum_admin'," `id` = '$fid'");
	  echo"删除成功<br/>";
    echo "正在自动返回.......<br/><a href=\"admin.php?action=forum_admin&act=bzgl&fid=$qid\">请手动返回</a><br/><meta http-equiv=refresh content='3;url=admin.php?action=forum_admin&act=bzgl&fid=$qid'>";
}else if($act=='scqz'){
    $row=$db->get_one('forum_admin',"  `id` ='$fid'",'');
    $rowbz=$db->get_one('forum_class_fl'," `id` ='$row[cid]'",'');
    $xxsj="你好！你在【[url=index.php?$bzml=forum&amp;fid=$rowbz[id][bzsid]]$rowbz[name][/url]】区主权限，被管理员解除。";
    Bingz_message_post('0',$row[uid],$xxsj);
    $db->delete('forum_admin'," `id` = '$fid'");
	  echo"删除成功<br/>";
    echo "正在自动返回.......<br/><a href=\"admin.php?action=forum_admin&act=qzgl&fid=$qid\">请手动返回</a><br/><meta http-equiv=refresh content='3;url=admin.php?action=forum_admin&act=qzgl&fid=$qid'>";
}else if($act=='bzgl'){
      $sql_li=$db->query('forum_class'," `id` ='$fid' ORDER BY `id`",'');
	    while($row=mysql_fetch_array($sql_li)){
           echo "<div class=\"admin\">板块 [$row[name]] - <a href=\"admin.php?action=forum_admin&act=zjbz&fid=$row[id]\">添加版主</a></br></div>";
           $sql_qz=$db->query('forum_admin'," `type` ='0'  AND `fid` ='$row[id]' ORDER BY `id`",'');
	         while($rowa=mysql_fetch_array($sql_qz)){
               $hysj=$db->get_one('user'," `uid` ='$rowa[uid]'",'');
               echo "<div class=\"admin_a\">会员：<a href=\"index.php?".$_config['qtxtpz']['mlwjmc']."=user&uid=$hysj[uid]$bzsid\">$hysj[name]</a> 
                - <a href=\"admin.php?action=forum_admin&act=scbz&fid=$rowa[id]&qid=$row[id]\">解除版主</a></div>";
	         }
           echo "</div>";
	    }
}else if($act=='qzgl'){
      $sql_li=$db->query('forum_class_fl'," `id` ='$fid' ORDER BY `id`",'');
	    while($row=mysql_fetch_array($sql_li)){
           echo "<div class=\"admin\">区块 [$row[name]] - <a href=\"admin.php?action=forum_admin&act=zjqz&fid=$row[id]\">添加区主</a></br></div>";
           $sql_qz=$db->query('forum_admin'," `type` ='1'  AND `fid` ='$row[id]' ORDER BY `id`",'');
	         while($rowa=mysql_fetch_array($sql_qz)){
               $hysj=$db->get_one('user'," `uid` ='$rowa[uid]'",'');
               echo "<div class=\"admin_a\">会员：<a href=\"index.php?".$_config['qtxtpz']['mlwjmc']."=user&uid=$hysj[uid]$bzsid\">$hysj[name]</a> 
                - <a href=\"admin.php?action=forum_admin&act=scqz&fid=$rowa[id]&qid=$row[id]\">解除区主</a></div>";
	         }
           echo "</div>";
	    }
}else{
   echo'<div class="admin">论坛版主管理<br/></div>';
   $sql_fi=$db->query('forum_class_fl',"1 ORDER BY `px`",'');
   while($aaw=mysql_fetch_array($sql_fi)){
      echo "<div class=\"admin_b\">【<a href=\"admin.php?action=forum_admin&act=qzgl&fid=$aaw[id]\">$aaw[name]</a>】-<a href=\"admin.php?action=forum_admin&act=zjqz&fid=$aaw[id]\">添区主</a></br><b><font color=#ff0000>区主</font>:</b>";
      $sql_qz=$db->query('forum_admin'," `type` ='1'  AND `fid` ='$aaw[id]' ORDER BY `id`",'');
	         while($rowa=mysql_fetch_array($sql_qz)){
               $hysj=$db->get_one('user'," `uid` ='$rowa[uid]'",'');
               echo "<a href=\"admin.php?action=forum_admin&act=qzgl&fid=$aaw[id]\">$hysj[name]</a> .";
	         }
      echo "</div>";
      $sql_li=$db->query('forum_class'," `fid` ='$aaw[id]' ORDER BY `px`",'');
	    while($rowa=mysql_fetch_array($sql_li)){
           echo "<div class=\"admin_a\">板块：[<a href=\"admin.php?action=forum_admin&act=bzgl&fid=$rowa[id]\">$rowa[name]</a>] - <a href=\"admin.php?action=forum_admin&act=zjbz&fid=$rowa[id]\">添加版主</a></br><font color=#FF8E44>版主</font>:";
           $sql_qz=$db->query('forum_admin'," `type` ='0'  AND `fid` ='$rowa[id]' ORDER BY `id`",'');
	         while($row=mysql_fetch_array($sql_qz)){
                $hysj=$db->get_one('user'," `uid` ='$row[uid]'",'');
               echo "<a href=\"admin.php?action=forum_admin&act=bzgl&fid=$rowa[id]\">$hysj[name]</a> .";
	         }
           echo "</div>";
	    }
	}
}
echo "<a href=\"admin.php?action=forum_admin&\">返回论坛管理</a><br/>";
?>